package com.imoblife.brainwavestus.newdownloadframe;

import java.util.HashMap;

import com.imoblife.brainwavestus.adapter.ProductBuyAdapter.ProductBuyViewHolder;
import com.imoblife.brainwavestus.product.Store;

public class DownloadThread extends Thread {
	
	private Store mStore;
	private ProductBuyViewHolder mViewHolder;
	private boolean isTheadRunning;
	private int progress;
	private HashMap<String, ProductBuyViewHolder> map;
	private Object object;
	
	public DownloadThread(ProductBuyViewHolder holder) {
		
		mViewHolder = holder;
	}
	
	public void setMap(HashMap<String, ProductBuyViewHolder> initMap){
		
		map = initMap;
	}
	
	public void setViewHodler(ProductBuyViewHolder holder){
		
		mViewHolder = holder;
	}
	
	public void setStore(Store store) {
	
		mStore = store;
	}
	
	@Override
	public void run() {
		
		String productName = mStore.getRecentDownloadTask();
		
		while(productName != null) {
			
			//mViewHolder = map.get(productName);
			progress = 0;
			
			for (int i = 0; i <= 100; i++) {
				progress+=1;
				
				System.out.println(progress+"progress的值是多少");
				mViewHolder.pb.setMax(100);
				mViewHolder.pb.setProgress(progress);				
			}
			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			productName = mStore.getRecentDownloadTask();
		}
	}

	public boolean isTheadRunning() {
		return isTheadRunning;
	}

	public void setTheadRunning(boolean isTheadRunning) {
		this.isTheadRunning = isTheadRunning;
	}

}
